import 'package:flutter/material.dart';
import 'package:xvideos/tools_base/widget/keep_alive_widget.dart';

import 'ai_record_page.dart';

class AIMainRecordPage extends StatefulWidget {
  final int position;

  const AIMainRecordPage({super.key, this.position = 0});

  @override
  State<StatefulWidget> createState() {
    return _AIMainRecordPageState();
  }
}

class _AIMainRecordPageState extends State<AIMainRecordPage> with TickerProviderStateMixin {
  List<String> tabs = ['科技脱衣', '视频换脸', '图片换脸'];
  String selectTitle = "";
  int selectIndex = 0;
  int selectedRadioIndex = 0;
  late final TabController tabCtr = TabController(length: 3, vsync: this, initialIndex: widget.position);

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('生成记录')),
      body: Column(
        children: [
          _buildTabbar(),
          Expanded(
            child: TabBarView(
              controller: tabCtr,
              children: <Widget>[
                AiRecordPage(position: 0).keepAlive,
                AiRecordPage(position: 1).keepAlive,
                AiRecordPage(position: 2).keepAlive,
              ],
            ),
          ),
        ],
      ),
    );
  }

  _buildTabbar() {
    return Container(
      height: 35,
      padding: EdgeInsets.symmetric(horizontal: 25),
      child: TabBar(
        controller: tabCtr,
        tabs: List.generate(
          tabs.length,
          (index) => Padding(
            padding: const EdgeInsets.only(top: 6, bottom: 3),
            child: Text(tabs[index]),
          ),
        ),
        labelPadding: EdgeInsets.zero,
        labelColor: Colors.white.withOpacity(.9),
        labelStyle: TextStyle(
          fontSize: 14,
          fontWeight: FontWeight.w500,
        ),
        unselectedLabelColor: Colors.white.withOpacity(.35),
        unselectedLabelStyle: const TextStyle(fontSize: 14, fontWeight: FontWeight.w400),
        indicator: BoxDecoration(),
      ),
    );
  }
}
